from django.contrib import admin


class IdSearchAdmin(admin.ModelAdmin):
    def get_search_results(self, request, queryset, search_term):
        qs, use_distinct = super().get_search_results(request, queryset, search_term)
        term = (search_term or '').strip()
        if term.isdigit():
            try:
                qs = queryset.filter(pk=int(term)) | qs
            except Exception:
                pass
        return qs, use_distinct

# Register your models here.
